﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
namespace lcreport.Web.reportinfo
{
    public partial class Show : Page
    {
        public string strid = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["admin"] == null)
            {
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "请先登录！", "../admin/login.aspx");

            }
            else
            {
                if (!Page.IsPostBack)
                {
                    if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
                    {
                        strid = Request.Params["id"];
                        int rid = (Convert.ToInt32(strid));
                        ShowInfo(rid);
                    }
                }
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            //divAdd.Visible = false;//需要隐藏的div
            string strFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
            Response.Buffer = true;
            System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + strFileName);
            Response.ContentType = "application/ms-excel";
            HttpContext.Current.Response.Charset = "UTF-8";
            this.EnableViewState = false;//初始化HtmlWriter
            System.IO.StringWriter writer = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(writer);
            this.myp.RenderControl(htmlWriter);//输出
            HttpContext.Current.Response.Write(writer.ToString());
            HttpContext.Current.Response.End();
        }

        private void ShowInfo(int rid)
        {
            lcreport.BLL.reportinfo bll = new lcreport.BLL.reportinfo();
            lcreport.Model.reportinfo model = bll.GetModel(rid);
            this.lblrname.Text = model.rname;
            this.Title = model.rname;
            this.lblrtel.Text = model.rtel;
            this.lblremail.Text = model.remail;
            this.lblrdiqu.Text = model.rdiqu;
            this.lblradd.Text = model.radd;
            //this.lblrssd.Text = model.rssd;
            this.lblrwork.Text = model.rwork;
            this.lblrobject.Text = model.robject;
            this.lblrtype.Text = model.rtype;
            this.lblrtypesub.Text = model.rtypesub;
            this.lblrtitle.Text = model.rtitle;
            this.lblrtext.Text = model.rtext;
            this.lblrdate.Text = model.rdate.ToString();
            if (model.rfile1.Trim() != "")
                this.lblrfile1.Text = "<a href='" + model.rfile1.Trim() + "'>附件1</a>";
            if (model.rfile2.Trim() != "")
                this.lblrfile2.Text = "<a href='" + model.rfile2.Trim() + "'>附件2</a>";
            if (model.rfile3.Trim() != "")
                this.lblrfile3.Text = "<a href='" + model.rfile3.Trim() + "'>附件3</a>";
            if (model.rfile4.Trim() != "")
                this.lblrfile4.Text = "<a href='" + model.rfile4.Trim() + "'>附件4</a>";
            if (model.rfile5.Trim() != "")
                this.lblrfile5.Text = "<a href='" + model.rfile5.Trim() + "'>附件5</a>";
            this.lblrresult.Text = model.rresult;

        }


    }
}
